package com.nbpt;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

public class HomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                int i = 1;
                while (true) {
                    Log.e("HomeActivity", "取外卖" + i);
                    i++;
                    try {
                        Thread.sleep(100);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }
        });

        thread1.start();

        MyThread thread2 = new MyThread();
        thread2.start();
    }
    class MyThread extends Thread{
        @Override
        public void run() {
            super.run();
            int i = 1;
            while (true) {
                Log.e("HomeActivity", "写作业" + i);
                i++;
            }
        }
    }
}
